/**
 * 
 */
package toutiao;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/**
 * @author zhongfang
 *
 */
public class 编程1 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		int N=scanner.nextInt();
		int[][] P=new int[N][2];
		ArrayList<int[]> outs=new ArrayList<>();
		for (int i = 0; i < N; i++) {
			P[i][0]=scanner.nextInt();
			P[i][1]=scanner.nextInt();
		}
		Arrays.sort(P, new Comparator<int[]>() {

			@Override
			public int compare(int[] o1, int[] o2) {
				return o2[0]-o1[0];
			}
		});
		int maxY=-1;
		for (int i = 0; i < P.length; i++) {
			if(maxY>P[i][1]){//有x，y都比i大的，i不是结果
				
			}else {
				System.out.println(P[i][0]+" "+P[i][1]);
				maxY=P[i][1];
			}
//			maxY=Math.max(maxY, P[i][1]);
		}
	}
}
